﻿Imports System.Linq
Imports SISSAT.BusinessLayer.Services
Imports SISSAT.BusinessLayer.DomainModels

Namespace Views
    Public Class GradePresenter

        Private Property View As IGradeView
        Private Property CourseService As ICourseService
        Private Property ScheduleService As IScheduleService

        Public Sub New(view As IGradeView)
            CourseService = New CourseService
            ScheduleService = New ScheduleService

            Me.View = view
            AddHandler Me.View.OnInitialization, AddressOf OnInitialization
        End Sub

        Private Sub OnInitialization()
            If Me.View.ScheduleId < 1 Then
                Return
            End If

            Dim schedule As Schedule = ScheduleService.ReadById(Me.View.ScheduleId)
            Me.View.RoomNumber = schedule.RoomNumber
            Me.View.ScheduleDay = schedule.ScheduleDay
            Me.View.ScheduleTime = schedule.ScheduleTime

            If Me.View.InstructorId > 0 Then
                Me.View.IsUserAnInstructorForSchedule = (schedule.Employee.EmployeeId = Me.View.InstructorId)
            End If
        End Sub

    End Class
End Namespace

